<template xmlns:v-on="http://www.w3.org/1999/xhtml">
  <div class="contains">
    <div>
      <swiper :options="swiperOption" ref="mySwiper" class="banner">
        <!-- 这部分放你要渲染的那些内容 -->
        <swiper-slide v-for="(item,index) in list" :key="item.id">
          <img class="img" :src="item.imgUrl" @click="clickImg(index)"/>
        </swiper-slide>
        <!-- 这是轮播的小圆点 -->
        <div class="swiper-pagination" slot="pagination"></div>
      </swiper>
    </div>
  </div>
</template>

<script>

  export default {
    name: 'contains',
    props: {list: Array},
    data () {
      return {
        swiperOption: {
          autoplay: 3000,
          pagination: '.swiper-pagination',
          loop: true
        }
      }
    },
    methods: {
      clickImg (index) {
        alert(index)
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus" rel="stylesheet/stylus">
  .banner >>> .swiper-pagination-bullet-active
    background-color white

  .banner
    height: 0
    padding-bottom: 31.25%
    overflow hidden
    background-color: #eee
    position relative

    .img
      width 100%
</style>
